def letterCasePermutation(s):
    """
    :type s: str
    :rtype: List[str]
    """
    def backtrack(sub="", i=0):
        # 如果已经遍历完字符串，则将当前组合加入结果集
        if i == len(s):
            result.append(sub)
            return
        
        # 如果当前字符是字母，则分别加入小写和大写形式
        if s[i].isalpha():
            backtrack(sub + s[i].lower(), i + 1)
            backtrack(sub + s[i].upper(), i + 1)
        else:
            # 如果当前字符是数字，则直接加入
            backtrack(sub + s[i], i + 1)

    result = []
    backtrack()
    return result
